include("shared.lua")


function SWEP:Initialize()
end


function SWEP:Think()
	GHOST:Think()
end

function SWEP:Deploy()
	self:CreateGhost()
end

function SWEP:Holster()

    GHOST:DestroyGhost()
    
end

function SWEP:CreateGhost()
	GHOST:CreateGhost()
end	

function SWEP:PrimaryAttack()

	if BUILDING:CanSpawn( GHOST.Entity ) then
		RunConsoleCommand("garc_spawn", BUILDING:Get() )
		GHOST:ResetTimer()
	end

end

hook.Add("KeyPress", "GarcBuilder", function( ply, btn )

	if btn == IN_ATTACK2 then
		
		local wep = LocalPlayer():GetActiveWeapon()
		
		if IsValid( wep ) && wep:GetClass() == "garc_builder" then
			BUILDING:OpenPanels()
		end
		
	end

end )

hook.Add("KeyRelease", "GarcBuilder", function( ply, btn )

	if btn == IN_ATTACK2 then
		BUILDING:ClosePanels()		
	end

end )
